<?php
/**
* Synthesis Framework
* Copyright (C) 2009 Chris Grams, Zeb DeOs
*
* This file is part of Synthesis Framework.
* 
* Synthesis Framework is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* 
* Synthesis Framework is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
* 
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
* 
* Your license is located in gpl-2.0.txt
*/

/**
* User Editable Settings
*/

/**
* Synthesis Core Path
*
* Location of the Synthesis core directory which may be the directory name where the directory is
* located in the same directory as this file, or a complete path to the core directory.
*/
$core_path = "core";

/**
* Extensions Path
*
* Location of the extensions directory where custom code is stored. This may either be just a
* directory name, in which case it is located inside the core directory, or it may be the complete
* path to the extensions directory.
*/
$ext_path = "extensions";

/**
* PHP Error Reporting
*
* This is useful to set to E_ALL for debugging, but set to 0 for a live website.
*/
error_reporting(E_ALL);

/**
* End of User Editable Settings
*/

/**
* Process the path settings and make sure the directories exist.
*/
$paths[] = &$core_path;
$paths[] = &$ext_path;

foreach($paths as $k => $p)
{
	/* if there are no directory separators, assume that this is just a directory name */
	if((strpos($p, "/") === FALSE) && (strpos($p, "\\") === FALSE))
	{
		/* assume that the 0th array item is the core directory */
		if($k === 0)
		{
			$p = pathinfo(__FILE__, PATHINFO_DIRNAME) . "/{$p}/";
		}
		
		/* all other directories are based on the core directory unless they have full paths set */
		else
		{
			$p = $paths[0] . $p . "/";
		}
	}
	
	/* if there are directory separators, clean them up */
	else
	{
		$p = str_replace("\\", "/", $p);
		if($p[strlen($p)-1] !== "/")
		{
			$p .= "/";
		}
	}
	
	/* make sure that the directories exist */
	if(is_dir($p) === FALSE)
	{
		exit("Path configuration error.");
	}
	
	$paths[$k] = $p;
}

/**
* Set some basic constants so that we don't have to global() all the important stuff
*/
define("SYNTH", 1);
define("INDEX", pathinfo(__FILE__, PATHINFO_BASENAME));
define("EXT", "." . pathinfo(__FILE__, PATHINFO_EXTENSION));
define("COREPATH", $core_path);
define("EXTPATH", $ext_path);

/**
* Clean off the table before synthesis begins
*/
unset($core_path, $ext_path, $paths, $k, $p);

/**
* Begin Synthesis Framework
*/
require_once(COREPATH . "synthesis/synthesis" . EXT);